package com.stu.wgt.test.service.Imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.stu.wgt.test.bean.ProductPictrurl;
import com.stu.wgt.test.mapper.ProductPictrurlMapper;
import com.stu.wgt.test.service.ProductPictrurlService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author wgt
 * @since 2024-02-19
 */
@Service
public class ProductPictrurlServiceImpl extends ServiceImpl<ProductPictrurlMapper, ProductPictrurl> implements ProductPictrurlService {

    @Autowired
    ProductPictrurlMapper productPictrurlMapper;

    @Override
    public int insert(ProductPictrurl productPictrurl) {
        return productPictrurlMapper.insert(productPictrurl);
    }

    @Override
    public int delete(int id) {
        return productPictrurlMapper.deleteById(id);
    }

    @Override
    public int update(ProductPictrurl productPictrurl) {
        QueryWrapper<ProductPictrurl> qw = new QueryWrapper<>();
        qw.eq("id", productPictrurl.getProductId());
        return productPictrurlMapper.update(productPictrurl, qw);
    }

    @Override
    public int updataByProductId(ProductPictrurl productPictrurl) {
        QueryWrapper<ProductPictrurl> qw = new QueryWrapper<>();
        qw.eq("product_id", productPictrurl.getProductId());
        return productPictrurlMapper.update(productPictrurl, qw);
    }

    @Override
    public List<ProductPictrurl> selectAllProductPictrurl() {
        return productPictrurlMapper.selectList(null);
    }

    @Override
    public List<ProductPictrurl> selectById(int productId) {
        QueryWrapper<ProductPictrurl> qw = new QueryWrapper<>();
        qw.eq("product_id", productId);
        return productPictrurlMapper.selectList(qw);
    }
}
